from django.forms import widgets
from rest_framework import serializers
from wechatApp.models import Scene, Line

class SceneSerializer(serializers.Serializer):
	id=serializers.IntegerField(read_only=True)
	title=serializers.CharField(required=True, allow_blank=False, max_length=200)
	desc=serializers.CharField(required=False, allow_blank=True, max_length=1000)

	def create(self,validated_data):
		return Scene.objects.create(**validated_data)

	def update(self, instance, validated_data):
		instance.title=validated_data.get('title',instance.title)
		instance.desc=validated_data.get('desc',instance.desc)
		instance.save()
		return instance
